package me.sdevil507.biz.common.area.mapper;

import me.sdevil507.biz.common.area.dto.CommonAreaParamsDto;
import me.sdevil507.biz.common.area.dto.CommonAreaResultDto;
import me.sdevil507.biz.common.area.po.CommonAreaPo;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 地区码表[CommonAreaMapper]
 *
 * @author sdevil507
 * created on 2020-07-02 14:15:14
 */
@Component
@Mapper(componentModel = "spring", nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface CommonAreaMapper {

    /**
     * po => dto
     *
     * @param po 实体类
     * @return dto传输类
     */
    CommonAreaResultDto po2dto(CommonAreaPo po);

    /**
     * pos => dtos
     *
     * @param pos 实体类集合
     * @return dtos传输类集合
     */
    List<CommonAreaResultDto> pos2dtos(List<CommonAreaPo> pos);

    /**
     * dto => po
     *
     * @param dto 传输类
     * @return po实体类
     */
    CommonAreaPo dto2po(CommonAreaParamsDto dto);

    /**
     * dtos => pos
     *
     * @param dtos 传输类集合
     * @return pos实体类集合
     */
    List<CommonAreaPo> dtos2pos(List<CommonAreaParamsDto> dtos);

    /**
     * 使用dto更新po
     *
     * @param dto 传输类
     * @param po  实体类
     */
    void updatePoFromDto(CommonAreaParamsDto dto, @MappingTarget CommonAreaPo po);
}